<?php 

class at_l_d_b_model extends CI_Model {
        function __construct()
        {
                parent::__construct();        
                $this->load->helper("local");
                $this->load->helper("local1");
                $this->load->helper('date');
				$this->load->library('pagination');
                $this->load->database();
        } 
//START-----------------at-------------------------// 

function getPage($limit,$rownum){
	 
		$config['base_url'] = base_url().'at_l_d_b/index/';
		$config['total_rows'] = $this->db->get('available_truck')->num_rows();
		$config['per_page'] = $limit;
		$config['full_tag_open'] = '<div id="pagination"';
		$config['full_tag_close'] = '</div>';
		$config['first_tag_open']='<a>';
		$config['first_tag_close']= '</a>';
		$this->pagination->initialize($config);
		
		return $this->db->get('available_truck', $config['per_page'],$rownum )->result_array();
		
}
function get_all_at_l_d_b_p($num, $offset) {
   
    $sql = "select * from available_truck";
	$sql.=" order by drop_off_date ASC, drop_off_state ASC";
	 	
//echo $sql;
//exit;  

	$query = $this->db->query ( $sql);
	return $query->result();
	
	
	}   
		function get_all_at_l_d_b()
        {
			    $this->load->database();
                $query = $this->db->query("select * from available_truck where drop_off_state LIKE'CA' order by drop_off_date ASC, drop_off_state ASC LIMIT 10");
				return $query->result();
        }
		
		
		
		
		
		
		
		
		function get_at($sortval,$IsDropOff)
       {     
	   $sql = "select * from available_truck ";
	   $key = "";
	   
		if($IsDropOff==true)
			$key ="drop_off_";
		else
			$key ="des_";

	   $query = $this->db->query($sql . " order by " . $key . $sortval . " asc ");
				return $query->result();
       }
	
	/*	function get_at2($sortval)
       {     
	   $sql = "select * from available_truck where drop_off_state LIKE'CA' ";
	   $query = $this->db->query($sql . " order by " . $sortval . " asc ");
				return $query->result();
       }
	  */ 
		function get_atsort($sortval)
       {     
	   $sql = "select * from available_truck where drop_off_state LIKE'CA'";
	   $query = $this->db->query($sql . " order by " . $sortval . " asc ");
				return $query->result();
       }
	   
	   function get_at2($search_value,$column_value)
       {    
		//$query = $this->db->query($sql . " order by " . $column_value . " asc Limit 10 ");
		$sql="select * from available_truck";
		$sql.=" where drop_off_state like'CA' and $column_value like '%$search_value%' ";
		$sql.="order by at_id ASC";
		
	//echo $sql;
	//exit;
		//$query = $this->db->query ("select * from vendor_payments where $column_value like '%$search_value%' order by dv_payment_id ASC Limit 10");
				$query = $this->db->query ($sql);
				return $query->result();
				
       }   

        function getat_l_d_b_info($code)
        {       $query = $this->db->query ("select * from available_truck where at_id='$code'");
				return $query->row();
        }
	    function getat_l_d_bInfoByLoadNo($load_no,$f_name,$dv_company_name,$drop_off_city,$drop_off_state,$drop_off_date,$type_of_truck,$mc_num,$des_city,$des_state,$des_zone)
        {       $query = $this->db->query ("select * from available_truck where load_no='$load_no'");
				return $query->row();
       }
	   
	   function getat_l_d_bInfoBydv_company_name($dv_company_name)
       {       $query = $this->db->query ("select * from dv_profile where dv_company_name='$dv_company_name' ");
				return $query->row();
       }
	   
	      function deleteinfo($at_id)
       {       $query = $this->db->query ("delete from available_truck where at_id=$at_id order by at_id desc");
				return true;
       }

//select vl.*,p.profile_id from profile p inner join vendor_at vl on vl.vendor_id=p.profile_id where vendor_id='$code'

//End-----------------at-------------------------//              		

}

?>